package velha.connection.bt;

import java.io.IOException;
import javax.microedition.lcdui.*;
import velha.Menu;
import velha.VelhaMIDlet;

public class BTMenu extends List implements CommandListener {
    private final VelhaMIDlet vmid;

    public BTMenu(VelhaMIDlet vmid) {
        super("Novo Jogo", List.IMPLICIT);

        this.vmid = vmid;

        try {
            append("Criar jogo", Image.createImage("/img/criar.png"));
            append("Procurar jogo", Image.createImage("/img/procurar.png"));
        } catch (IOException ex) {
        }

        addCommand(new Command("Voltar", Command.BACK, 0));
        setCommandListener(this);
    }

    public void commandAction(Command c, Displayable d) {
        if ("Voltar".equals(c.getLabel())) {
            vmid.getDisplay().setCurrent(new Menu(vmid));
        } else if (c == SELECT_COMMAND) {
            switch (getSelectedIndex()) {
                case 0:
                    GUIServidor servidor = new GUIServidor(vmid);
                    break;
                case 1:
                    GUICliente cliente = new GUICliente(vmid);
                    break;
            }
        }
    }
}
